package com.fafi.spring.test.factorybean;

import com.fafi.spring.test.bean.SimpleBean;
import org.springframework.beans.factory.FactoryBean;

public class SelfFactorybean implements FactoryBean {
	private String message;

	public SelfFactorybean() {
		this.message = "通过构造方法初始化实例";
	}

	@Override
	public Object getObject() throws Exception {
		SimpleBean myBean = new SimpleBean();
		myBean.message = "通过FactoryBean.getObject()创建实例";
		// 这里并不一定要返回MyBean自身的实例，可以是其他任何对象的实例
		return myBean;
	}

	@Override
	public Class<?> getObjectType() {
		return SimpleBean.class;
	}

	public String getMessage() {
		return message;
	}
}
